package org.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.entity.Role;
import org.example.mapper.RoleMapper;
import org.example.service.IRoleService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
    @Override
    public PageInfo<Role> listByPage(Integer page, Integer limit, String searchRoleName) {
        PageHelper.startPage(page, limit);
        LambdaQueryWrapper<Role> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(searchRoleName != null){
            lambdaQueryWrapper.like(Role::getRoleName,searchRoleName);
        }
        List<Role> list = this.list(lambdaQueryWrapper);
        PageInfo<Role> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
